Package org.netbeans.modules.languages.pl_sql.editor.explorer.nodes

Source Code of org.netbeans.modules.languages.pl_sql.editor.explorer.nodes.LocalFileEditor

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.netbeans.modules.languages.pl_sql.editor.explorer.nodes;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.beans.PropertyEditorSupport;
import java.io.File;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import org.openide.util.Exceptions;

/**
*
* @author SUMsoft
*/
public class LocalFileEditor extends PropertyEditorSupport {

    @Override
    public Component getCustomEditor() {
        JFileChooser fc = new JFileChooser();
        fc.setDialogType(JFileChooser.SAVE_DIALOG);
        fc.setSelectedFile(new File((String) getValue()));
        fc.addActionListener(new AbstractAction() {

            public void actionPerformed(ActionEvent e) {
                if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
                    try {
                        setValue(((JFileChooser) e.getSource()).getSelectedFile().getCanonicalPath());
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            }
        });
        return fc;
    }

    @Override
    public boolean supportsCustomEditor() {
        return true;
    }
}
TOP

Related Classes of org.netbeans.modules.languages.pl_sql.editor.explorer.nodes.LocalFileEditor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.